package com.llxwz.util;


import com.llxwz.entity.User;
import org.springframework.stereotype.Component;

//相当于  线程隔离  的容器
//持有用户信息，代替session
@Component
public class HostHolder {

    //先获取当前线程，建一个map
    //key为当前线程，value为要存入的值
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user){
        users.set(user);
    }

    public User getUser(){
        return users.get();
    }

    public void clear(){
        users.remove();
    }

}
